Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util.format list issue #1099

Merged
merged 3 commits into from
Jul 9, 2024
Merged

util.format list issue #1099

merged 3 commits into from
Jul 9, 2024

Conversation

iowillhoit
Copy link
Contributor

@iowillhoit iowillhoit commented Jul 9, 2024

What does this PR do?

Note

We decided to postpone this change to collect information via telemetry. Once all missing specifiers have been corrected, we will enforce them. Follow up work will be completed in @W-16197665@

Caution

This is technically a breaking change. If we have a message somewhere that is missing a specifier, the tokens will no longer be rendered. This is a difficult thing to validate across our codebase. We could do a few things:

  • Wait until the next major release of sfdx-core
  • Add telemetry for when a specifier is missing and monitor it over the coming weeks
  • Only skip formatting if messages has a length greater than 1

This is a solution to prevent tokens from being rendered in a message when a specifier (e.g. %s) does not exist

If the message does not contain a specifier, node's util.format still appends the token to the end (docs)

This issue was discovered in sf whatsnew --help where the token for the specifier %s was being rendered at the end of each example. This was happening because the markdownLoader automatically splits bulleted lists into arrays.

We now check for the presence of a specifier and only format the message if one is present.

BEFORE:

Screenshot 2024-07-09 at 11 08 10 AM

AFTER:

Screenshot 2024-07-09 at 11 08 39 AM

Testing

  • Pull branch
  • yarn build
  • yarn link
  • cd to plugin-info
  • yarn link @salesforce/core
  • bin/run.js whatsnew --help

What issues does this PR fix or reference?

@W-16188160@

@iowillhoit iowillhoit requested a review from a team as a code owner July 9, 2024 16:21
@iowillhoit iowillhoit requested a review from mdonnalley July 9, 2024 16:21
// This causes the token to be appended to each line regardless of the presence of a specifier.
// Here we check for the presence of a specifier and only format the message if one is present.
// https://nodejs.org/api/util.html#utilformatformat-args
// https://regex101.com/r/8Hf8Z6/1
Copy link
Contributor

@mdonnalley mdonnalley Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a link to the regex is brilliant 🏆

mdonnalley
mdonnalley previously approved these changes Jul 9, 2024
@mdonnalley
Copy link
Contributor

mdonnalley commented Jul 9, 2024

QA

🟢 tokenized input only occurs once in markdown list with single %s
🟢 tokenized input occurs in appropriate places with multiple %s
🟢 tokenized input correctly rendered in markdown string "list"

@iowillhoit
Copy link
Contributor Author

Here is an example console.logging a pseudo telem event (ignore the Error, it is unrelated)
Screenshot 2024-07-09 at 1 44 30 PM

@mdonnalley mdonnalley merged commit 4c56d31 into main Jul 9, 2024
72 checks passed
@mdonnalley mdonnalley deleted the ew/list-token-bug branch July 9, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants